//Client.java
package memento.blackbox;

/**
 *@author:youtubezou
 *@version:2012-8-16
 */
public class Client
{
	public static void main(String[] args) throws InterruptedException
	{
		final int SEC = 1000;
		User user = new User("Tom");
		
		user.setState("Happy");
		System.out.println(user);
		//Thread.sleep(3 * SEC);	//this is alternate
		synchronized(user){
			user.wait(3000);
		}
		user.saveState();
		user.setState("Angry");
		System.out.println(user);
		Thread.sleep(2 * SEC);
		
		/**
		 * return : memento.blackbox.User$WideMemento
		 * Indicate: class object won't change to superclass's class object.
		 */
		System.out.println(user.peekMemento().getClass().getName());
		
		System.out.println("Manager comes...");
		Thread.sleep(2 * SEC);
		user.restoreState();
		System.out.println(user);
		
		
		
	}

}
